#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main() {
	freopen("sub.in", "r", stdin);
	freopen("sub.out", "w", stdout);
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int T;
	cin >> T;
	while(T--) {
		int a, b;
		cin >> a >> b;
		if(a >= 0 && b >= 0 || a <= 0 && b <= 0) cout << "0\n";
		else cout << min(abs(a), min(abs(b), abs(a + b))) << '\n';
	} 
	return 0;
}

